{layout name="p/base" /}

<link rel="stylesheet" href="http://cache.amap.com/lbs/static/main1119.css"/>
<script type="text/javascript"
        src="http://webapi.amap.com/maps?v=1.3&key=a7e2fc1a96a83283106bf583328aa248&plugin=AMap.Autocomplete"></script>
<script type="text/javascript" src="http://cache.amap.com/lbs/static/addToolbar.js"></script>
<form class="form-horizontal" role="form" id='addcamp' action="/camp/{$list.id}" method="post" >
  <div id="page-wrapper">
    <div class="row">
      <div class="col-lg-12">
        <h1>营地管理 <small>营地信息编辑</small></h1>
        <ol class="breadcrumb">
          <li><a href="/campmanagerlist"><i class="fa fa-dashboard"></i> 管理首页</a></li>
          <li><a href="/camp"><i class="fa fa-dashboard"></i> 营地列表信息</a></li>
          <li class="active"><i class="fa fa-table"></i> 营地信息编辑</li>
        </ol>
        <div class="alert alert-success alert-dismissable">
          <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
          请准确编辑营地信息
        </div>
      </div>
    </div>
    <!-- /.row -->
    <div class="row">
      <!-- 选项卡start -->
      <div class="bs-example">
        <!-- 选项卡标题start -->
        <ul class="nav nav-tabs" style="margin-bottom:15px;">
          <li class="active">
            <a href="#one" data-toggle="tab">营地基本信息</a>
          </li>
          <li>
            <a href="#two" data-toggle="tab">营地介绍图文信息</a>
          </li>
        </ul>
        <!-- 选项卡标题end -->
        <!-- 选项卡内容start -->
        <div id="myTabContent" class="tab-content">
          <!-- 选项卡内容1会员类型start -->
          <div id="one" class="tab-pane fade active in">
            <!-- 基本信息start -->
            <div class="col-lg-11">
              <!-- 营地信息start -->
              
                <input type="hidden" name="_method" value="PUT" >
                  <div class="form-group">
                    <label class="control-label col-sm-2">营地编号</label>
                    <div class="col-sm-4">
                      <input class="form-control" type="text" disabled="disabled" name="number" value="{$list.number}" placeholder="sjz85468585">
                    </div>
                    <label class="control-label col-sm-2">营地名称</label>
                    <div class="col-sm-4">
                      <input class="form-control" type="text" disabled="disabled" name="name" value="{$list.name}" placeholder="请填写营地名称" >
                    </div>
                  </div>
                  <div class="form-group ">
                    <label for="firstname" class="control-label col-sm-2">营地类型</label>
                    <div class="col-sm-4">
                      <select class="form-control" name="type" disabled="disabled">
                      {foreach $types as $k => $type}
                      {if $list.type==$k}
                       <option value={$k} selected='true'>{$type}</option>
                       {else}
                       <option value={$k} >{$type}</option>
                       {/if}
                      {/foreach}
                      </select>
                    </div>
                    <label for="firstname" class="control-label col-sm-2">营地星级</label>
                    <div class="col-sm-4">
                    <select class="form-control" name="grade" disabled="disabled">
                      {foreach $grades as $k => $grade}
                      {if $list.grade==$k}
                       <option value={$k} selected='true'>{$grade}</option>
                       {else}
                       <option value={$k} >{$grade}</option>
                       {/if}
                      {/foreach}
                    </select>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="control-label col-sm-2">泊位数量</label>
                    <div class="col-sm-4">
                      <input class="form-control" type="text" disabled="disabled" name="count" value="{$list.count}" placeholder="请填写泊位数量">
                    </div>
                    <label class="control-label col-sm-2">营地描述</label>
                    <div class="col-sm-4">
                      <textarea class="form-control" type="text" name="profiles"  placeholder="请填写营地名称"> {$list.profiles}</textarea>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="control-label col-sm-2">超级管理员账号</label>
                    <div class="col-sm-4">
                      <input class="form-control" type="text" disabled="disabled" name="campmanager_phone" value="{$list.campmanager_phone}" placeholder="请填写超级管理员手机号码" />
                    </div>
                    <label class="control-label col-sm-2">超级管理员姓名</label>
                    <div class="col-sm-4">
                      <input class="form-control" type="text" disabled="disabled" name="campmanager_name" value="{$list.campmanager_name}" placeholder="请填写超级管理员姓名">
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="control-label col-sm-2">营地联系方式</label>
                    <div class="col-sm-4">
                      <input class="form-control" type="text" name="tel" value="{$list.tel}" placeholder="请填写营地联系方式" />
                    </div>
                    <label class="control-label col-sm-2">营地所属分公司</label>
                    <div class="col-sm-4">
                      <select class="form-control" name="branch" disabled="disabled">
                       <option value='石家庄' >石家庄</option>
                    </select>
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="control-label col-sm-2">邮箱</label>
                    <div class="col-sm-4">
                      <input class="form-control" type="text" name="email" value="{$list.email}" placeholder="请填写营地负责人邮箱" />
                    </div>
                    <label class="control-label col-sm-2">营地旅行币基数</label>
                    <div class="col-sm-4">
                      <input class="form-control" type="text" disabled="disabled" name="travel_money_base" value="{$list.travel_money_base}" placeholder="请填写旅行币基数" />
                    </div>
                  </div>
                  <div class="form-group">
                    <label class="control-label col-sm-2">法人代表</label>
                    <div class="col-sm-4">
                      <input class="form-control" type="text" disabled="disabled" name="legal_person" value="{$list.legal_person}" placeholder="请填写法人" />
                    </div>
                    <label class="control-label col-sm-2">统一社会信用代码</label>
                    <div class="col-sm-4">
                      <input class="form-control" type="text" disabled="disabled" name="credit_code" value="{$list.credit_code}" placeholder="请填写营业执照统一社会信用代码" />
                    </div>
                  </div>

                  <div class="form-group">
                    <label for="firstname" class="control-label col-sm-2">封面图片</label>
                    <div class="col-sm-2" style="width:875px; min-height:200px;">
                      <div id="caravancover" >
                          <!--用来存放item-->
                          <div id="fileList" class="uploader-list"></div>
                          <div id="filePicker" >选择图片</div>
                      </div>
                      {if !empty($list.cover['0'])}
                      <img src="{$list.cover['0']}">
                      {/if}
                    </div>
                  </div>

                  <div class="form-group">
                    <label for="firstname" class="control-label col-sm-2">营业执照</label>
                    <div class="col-sm-2" style="width:875px; min-height:200px;">
                      <div id="caravanphoto">
                          <!--用来存放item-->
                          <div id="fileList" class="uploader-list"></div>
                          <div id="filePicker">选择营业执照图片</div>
                      </div>
                      {if !empty($list.license['0'])}
                      <img src="{$list.license['0']}">
                      {/if}
                    </div>
                  </div>


                  <div class="form-group" id="addressD">
                    <label class="control-label col-sm-2">地址</label>
                    <select name="addressCountry" class="addressCountry" data-value="{$list.country}" data-first-title="选择国家" data-url="/camp/getcountry" style="width:100px;" ></select>
                    <select name="addressProvince" class="addressProvince" data-value="{$list.province}" data-first-title="选择省" data-url="/camp/getprovince" style="width:100px;"></select>
                    <select name="addressCity" class="addressCity" data-value="{$list.city}" data-first-title="选择城市" data-url="/camp/getcity" style="width:100px;"></select>
                  </div>

                  <!-- 详细地址 -->
                  <div class="form-group">
                    <label class="control-label col-sm-2">营地详细地址</label>
                    <div class="col-sm-4">
                      <input class="form-control" type="text" name="address" value="{$list.address}" placeholder="请填写营地的详细地址" />
                    </div>
                  </div>

                  <!-- 地图start -->
                  <div class="form-group">
                    <label for="firstname" class="control-label col-sm-2">营地地图</label>
                    <div class="col-sm-10 campmap">
                    <div id="container"></div>
                    <div id="myPageTop">
                      <table>
                        <tr>
                          <td>
                            <label>按关键字搜索：</label>
                          </td>
                          <td class="column2">
                            <label>左击获取经纬度：</label>
                          </td>
                        </tr>
                        <tr>
                          <td>
                            <input type="text" placeholder="请输入关键字进行搜索" id="tipinput">
                          </td>
                          <td class="column2">
                            <input type="text" readonly="true" id="lnglat">
                            <input type="text" name="lng" id='lng' value='{$list.lng}' />
                            <input type="text" name="lat" id='lat' value='{$list.lat}' />
                          </td>
                        </tr>
                      </table>
                    </div>
                    <script type="text/javascript">
                      var map = new AMap.Map("container", {
                        resizeEnable: true,
                        center:[{$list.lng},{$list.lat}],
                        zoom:15
                      });
                     var marker = new AMap.Marker({
                        position: [{$list.lng},{$list.lat}],
                        draggable: true,
                        cursor: 'move',
                        raiseOnDrag: true
                    });
                     marker.setMap(map);

                    //为地图注册click事件获取鼠标点击出的经纬度坐标
                    var clickEventListener = map.on('click', function(e) {
                      document.getElementById("lnglat").value = e.lnglat.getLng() + ',' + e.lnglat.getLat();
                      document.getElementById("lng").value = e.lnglat.getLng();
                      document.getElementById("lat").value = e.lnglat.getLat();
                    marker.setPosition([e.lnglat.getLng(),e.lnglat.getLat()])
                    });

                    var auto = new AMap.Autocomplete({
                      input: "tipinput"
                    });
                      AMap.event.addListener(auto, "select", select);//注册监听，当选中某条记录时会触发
                      function select(e) {
                        if (e.poi && e.poi.location) {
                          map.setZoom(15);
                          map.setCenter(e.poi.location);
                          document.getElementById("lnglat").value = e.poi.location.getLng() + ',' + e.poi.location.getLat();
                          document.getElementById("lng").value = e.poi.location.getLng();
                          document.getElementById("lat").value = e.poi.location.getLat();
                          marker.setPosition([e.poi.location.getLng(),e.poi.location.getLat()])
                        }
                      }
                    </script>                
                    </div>
                  </div>
              <!-- 营地信息end -->
            </div>
            <!-- 基本信息end -->
          </div>
          <!-- 选项卡内容1会员类型end -->
          <!-- 选项卡内容2级别start -->
          <div id="two" class="tab-pane fade">
            <!-- 基本信息start -->
             <div class="col-lg-12">
                <div class="form-group">
                    <!-- 营地信息end -->
                    <script id="editor" name="content" type="text/plain">
                        {$list.content}
                    </script>
                    
                </div>
              <div class="form-group">
                <div class="btn-group mybtn">
                  <button class="btn btn-primary" type="submit">提交</button>
                </div>
              </div>
            
            </div>
            <!-- 基本信息end -->
            
          </div>
          
          <!-- 选项卡内容2级别end -->
        </div>
        <!-- 选项卡内容end -->
      </div>
      <!-- 选项卡end -->
    </div>

  </div><!-- /#page-wrapper -->

</div><!-- /#wrapper -->
</form>
 


<!-- 世界城市地区联动 -->
<script src="/js/jquery.cxselect.js"></script>
<script>
  $('#addressD').cxSelect({
  selects: ['addressCountry','addressProvince', 'addressCity',],
  jsonName: 'area_name',
  jsonValue: 'area_code'  }, function(api) {
    cxSelectApi = api;
  });
</script>

<!-- 配置文件 -->
    <script type="text/javascript" src="/UEditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="/UEditor/ueditor.all.js"></script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
          UE.Editor.prototype.getActionUrl = function(action) {
              if (action == 'uploadimage' || action == 'uploadscrawl' || action == 'uploadimage') {
                  return '/user/upload';
              } else if (action == 'uploadvideo') {
                  return 'http://a.b.com/video.php';
              } else {
                  return this._bkGetActionUrl.call(this, action);
              }
          }

          var ue = UE.getEditor('editor',{toolbars: [[
                  'fullscreen', 'source', '|', 'undo', 'redo', '|',
                  'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                  'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                  'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                  'directionalityltr', 'directionalityrtl', 'indent', '|',
                  'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                  'link', 'unlink', 'anchor', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                  'simpleupload', 'insertimage', 'emotion', 'map', 'gmap', 'insertframe', 'insertcode', 'background', '|',
                  'horizontal', 'date', 'time', 'spechars', 'snapscreen', 'wordimage', '|',
                  'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
                  'print', 'preview', 'searchreplace', 'drafts', 'help'
              ]]});
          ue.addListener('ready', function() {
              ue.focus();
          });

        var ue = UE.getEditor('editor');
    </script>
<script type="text/javascript" src="/front/diyUpload/js/webuploader.js"></script>
<script type="text/javascript" src="/front/diyUpload/js/diyUpload.js"></script>
<script type="text/javascript">
  $(function(){
    /*
    * 服务器地址,成功返回,失败返回参数格式依照jquery.ajax习惯;
    * 其他参数同WebUploader
    */
    $('#caravancover').diyUpload1({
      url:'/camp/imgupload',
      success:function( data ) {
        $('#addcamp').append('<input type="hidden" name="caravancover" value="'+data.url+'" />'); 
      },
      error:function( err ) {
        // console.info( err ); 
      },
      buttonText : '选择房车封面',
      thumb:{
        width: 800,
          height: 200,
      }
    });
    $('#caravanphoto').diyUpload({
      url:'/camp/imgupload',
      success:function( data ) {
        $('#addcamp').append('<input type="hidden" name="license" value="'+data.url+'" />'); 
      },
      error:function( err ) {
        console.info( err );  
      },
      buttonText : '选择营业执照图片',
      chunked:true,
      // 分片大小
      chunkSize:512 * 1024,
      //最大上传的文件数量, 总文件大小,单个文件大小(单位字节);
      fileNumLimit:50,
      fileSizeLimit:500000 * 1024,
      fileSingleSizeLimit:50000 * 1024,
      accept: {},
      thumb:{
        width: 388,
          height: 200,
      }
    });
  });
</script> 